﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<link href="js-console.css" rel="stylesheet" />
	<!-- 7. Write an expression that checks if given positive 
			integer number n (n ≤ 100) is prime. E.g. 37 is prime. -->
</head>
<body>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		var number = prompt("Enter integer value <= 100");
		number *= 1;	// make it real number

		if (!isNaN(number) && number > 0 && number <= 100) {
			var foundDivisors = false;

			for (var i = 2; i < number && !foundDivisors; i++) {
				jsConsole.writeLine(i);
				if ((number % i) == 0) {
					foundDivisors = true;
				}
			}

			jsConsole.writeLine("Number " + number + " is " + (foundDivisors ? "composite." : "prime."));
		}
		else {
			jsConsole.writeLine("Wrong input.");
		}

	</script>
</body>
</html>
